home *** CD-ROM | disk | FTP | other *** search
/ Saturn 2 / Saturn 2 Edition.iso / utils / 250 / 250.exe / FILES1.LZH / BACKTAB.C < prev    next >
C/C++ Source or Header  |  1993-08-18  |  2KB  |  64 lines

  1. /*------------------------------------------------
  2.    BACKTAB.C -- Extension DLL for E! - version 1.0
  3.  
  4.    To compile: nmake /f backtab.mak
  5.  
  6.    Once compiled, copy BACKTAB.EWD to your USER directory.
  7.  
  8.    To use this DLL simply load it from the user menu or add its name to the
  9.    list of autoloaded Extension DLLs by using the Autoload dialog box from
  10.    the User Menu of EW. That's all.
  11.  
  12.    This extension DLL adds a new function to E!. It erases all text between
  13.    the current cursor position and the previous tab position, shifting all
  14.    the text after the cursor to the left.
  15.  
  16.    You can assign this extension to a keystroke (Ctrl Bsp would be nice).
  17.    See the documentation for a description of how to assign DLL execution
  18.    to a keystroke. Once assigned to a keystroke, an extension DLL needs not
  19.    be explicitly loaded. EW takes care of this for you.
  20.   ------------------------------------------------*/
  21.  
  22. #include <windows.h>
  23. #include <string.h>
  24. #include "ewapi.h"
  25.  
  26. int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
  27.             LPSTR lpszCmdLine)
  28. {
  29.   if (wHeapSize > 0)
  30.     UnlockData (0) ;
  31.   return 1 ;
  32. }
  33.  
  34. int FAR PASCAL EWExecute(unsigned int RoutineId)
  35. {
  36.   char LineBuffer[256];
  37.   WORD xPos1, xPos2, yPos, len;
  38.   long CaretPos1, CaretPos2;
  39.   HWND H;
  40.  
  41.   CaretPos1 = EWGetCaretPos();             // Get current caret position
  42.   xPos1 = LOWORD(CaretPos1);
  43.   yPos = HIWORD(CaretPos1);
  44.   _fstrcpy(LineBuffer, EWGetLineAt(yPos));   // Get current line
  45.   len = _fstrlen(LineBuffer);
  46.   if ((xPos1 != 0)
  47.   && (!EWGotoPrevTab())
  48.   && (xPos1 < len)){                 // Go to previous Tab position
  49.     CaretPos2 = EWGetCaretPos();
  50.     xPos2 = LOWORD(CaretPos2);
  51.     _fmemmove(LineBuffer + xPos2,         // Erase unwanted characters
  52.           LineBuffer + xPos1,
  53.           _fstrlen(LineBuffer + xPos1) + 1);
  54.     EWSetLineAt(LineBuffer, yPos);         // Move new line to actual text
  55.     H = EWGetTextWindowHandle();
  56.     InvalidateRect(H, NULL, FALSE);         // Repaint window
  57.     UpdateWindow(H);
  58.     EWSetModified();                 // Tell E! that the text has been modified
  59.     return(0);
  60.   }
  61.   else
  62.     return(ewerr_EXTFAILED);
  63. }
  64.